package com.jk.smartelderlycare.controller;

import com.jk.smartelderlycare.dto.SysCoupon;
import com.jk.smartelderlycare.dto.SysHomestay;
import com.jk.smartelderlycare.pojo.PagedResponse;
import com.jk.smartelderlycare.pojo.ResponseResult;
import com.jk.smartelderlycare.service.SysCouponServiceFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.common.recycler.Recycler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author hhk
 * @version 1.0
 * @ClassName SysCouponController
 * @program: smart-elderly-care
 * @description: TODO
 * @date 2024/11/28 20:50
 */
@Api(tags = "优惠劵管理模块")
@Slf4j
@RestController
@RequestMapping(value = "Coupon")
public class SysCouponController {
    @Autowired
    private SysCouponServiceFeign sysCouponServiceFeign;
    /** 
     * @description: 优惠劵后端分页查询
     * @param: [sysCoupon, pageNum, pageSize]
     * @return: com.jk.smartelderlycare.pojo.ResponseResult<com.jk.smartelderlycare.pojo.PagedResponse<com.jk.smartelderlycare.dto.SysCoupon>>
     * @author hhk
     * @date: 2024/11/28 20:54
     */ 
    @ApiOperation(value = "优惠劵后端分页查询", httpMethod = "POST", notes = "优惠劵后端分页查询")
    @PostMapping(value = "findSysCouponPaginationList")
    private ResponseResult<PagedResponse<SysCoupon>> findSysCouponPaginationList(@RequestBody SysCoupon sysCoupon, @RequestParam(value = "pageNum") Integer pageNum,@RequestParam(value = "pageSize") Integer pageSize){
        return new ResponseResult<>(200,"查询成功",sysCouponServiceFeign.findSysCouponPaginationList(sysCoupon,pageNum,pageSize));
    }
    /** 
     * @description: \addSysCoupon
     * @param: [sysCoupon]
     * @return: com.jk.smartelderlycare.pojo.ResponseResult
     * @author hhk
     * @date: 2024/11/28 20:56
     */ 
    @ApiOperation(value = "优惠劵添加", httpMethod = "POST", notes = "优惠劵添加")
    @PostMapping(value = "addSysCoupon")
    private ResponseResult addSysCoupon(@RequestBody SysCoupon sysCoupon){
        try {
            sysCouponServiceFeign.addSysCoupon(sysCoupon);
            return new ResponseResult(200,"添加成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(500,"添加失败");
        }
    }
    /** 
     * @description: 根据id删除一条优惠劵
     * @param: [couponId]
     * @return: com.jk.smartelderlycare.pojo.ResponseResult
     * @author hhk
     * @date: 2024/11/28 20:58
     */ 
    @ApiOperation(value = "根据id删除一条优惠劵", httpMethod = "DELETE", notes = "根据id删除一条优惠劵")
    @DeleteMapping(value = "deleteSysCouponById")
    private ResponseResult deleteSysCouponById(@RequestParam(value = "couponId") Long couponId){
        try {
            sysCouponServiceFeign.deleteSysCouponById(couponId);
            return new ResponseResult(200,"删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(500,"删除失败");
        }
    }
    /** 
     * @description: 根据id查询一条优惠劵
     * @param: [couponId]
     * @return: com.jk.smartelderlycare.pojo.ResponseResult<com.jk.smartelderlycare.dto.SysCoupon>
     * @author hhk
     * @date: 2024/11/28 21:00
     */ 
    @ApiOperation(value = "根据id查询一条优惠劵", httpMethod = "GET", notes = "根据id查询一条优惠劵")
    @GetMapping(value = "findSysCouponById")
    private ResponseResult<SysCoupon>findSysCouponById(@RequestParam(value = "couponId") Long couponId){
        return new ResponseResult<>(200,"查询成功",sysCouponServiceFeign.findSysCouponById(couponId));
    }
    /** 
     * @description: 修改优惠劵
     * @param: [sysCoupon]
     * @return: com.jk.smartelderlycare.pojo.ResponseResult
     * @author hhk
     * @date: 2024/11/28 21:02
     */ 
    @ApiOperation(value = "修改优惠劵", httpMethod = "PUT", notes = "修改优惠劵")
    @PutMapping(value = "updataSysCoupon")
    private ResponseResult updataSysCoupon(@RequestBody SysCoupon sysCoupon){
        try {
            sysCouponServiceFeign.updataSysCoupon(sysCoupon);
            return new ResponseResult(200,"修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(500,"修改失败");
        }
    }
    /**
     * @description: 民宿信息
     * @param: []
     * @return: com.jk.smartelderlycare.pojo.ResponseResult<com.jk.smartelderlycare.dto.SysHomestay>
     * @author hhk
     * @date: 2024/11/29 16:32
     */
    @ApiOperation(value = "查询所有民宿",httpMethod = "GET",notes = "查询所有民宿")
    @GetMapping(value = "findHomestayList")
    private ResponseResult<List<SysHomestay>> findHomestayList(){

            return new ResponseResult<>(200,"查询成功",sysCouponServiceFeign.findHomestayList());

    }
    
    
    
    
    
}
